# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=modifycerttemplate
_pkgname=modifyCertTemplate
pkgver=7.4c35708
pkgrel=5
pkgdesc='Aid operators in modifying ADCS certificate templates so that a created vulnerable state can be leveraged for privilege escalation.'
arch=('any')
groups=('blackarch' 'blackarch-windows')
url='https://github.com/fortalice/modifyCertTemplate'
license=('custom:unknown')
depends=('python' 'python-ldap3' 'impacket')
makedepends=('git')
source=("git+https://github.com/fortalice/$_pkgname.git")
sha512sums=('SKIP')

pkgver() {
  cd $_pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

package() {
  cd $_pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md

  rm README.md .gitignore requirements.txt

  cp -a * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
exec python /usr/share/$pkgname/modifyCertTemplate.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

